package com.sun.servlet;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author Sun
 * @Date 2020/4/19 22:57
 * @Version 1.0
 */
public class LoginRequest extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //处理请求
        //用Request对象拿到输入的请求参数
        String username = req.getParameter("username");
        String pwd = req.getParameter("pwd");
        System.out.println(username+":"+pwd);

        //用Response对象重定向，跳转到指定页面
        resp.sendRedirect("success.jsp");

    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
